package com.bestcem.xm.user.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * 公司限额统计信息
 *
 * @author yanjishuo <jishuo.yan@idiaoyan.com>
 * @version v1.0
 * @date 2022/05/06 15:24
 */

@Getter
@AllArgsConstructor
public enum QuotaConsumptionEnum {

    /**
     * 公司限额统计信息
     */
    USER("user_usage", "user_total", "累计用户数"),
    RESPONDENT("rspd_usage", "respondent_total", "累计答卷数"),
    PROJECT("project_usage", "project_total", "累计问卷数"),
    MEMBER_IND("member_ind_usage", "member_ind_total", "累计个人联系人"),
    DATASOURCE("datasource_usage", "datasource_total", "累计数据源数据");

    /**
     * 缓存key
     */
    private final String key;
    /**
     * 消息类型
     */
    private final String type;
    private final String desc;

    /**
     * 通过type获取
     *
     * @param type
     * @return
     */
    public static QuotaConsumptionEnum getByType(String type) {
        return Stream.of(values()).filter(s -> s.getType().equals(type)).findFirst().orElse(null);
    }
}
